<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>取得表名</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.mysql-tablename" class="refentry">
   <div class="refnamediv">
    <h1 class="refname">mysql_tablename</h1>
    <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">mysql_tablename</span> &mdash; <span class="dc-title">取得表名</span></p>

   </div>
   <div class="refsect1 unknown-unknown-seealsq" id="refsect1-function.mysql-tablename-unknown-unknown-seealsq">
    <h3 class="title">说明</h3>
    <div class="methodsynopsis dc-description">
     <span class="methodname"><strong>mysql_tablename</strong></span>
      ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$result</code></span>
     , <span class="methodparam"><span class="type">int</span> <code class="parameter">$i</code></span>
     ) : <span class="type">string</span></div>

    <p class="para rdfs-comment">
     <span class="function"><strong>mysql_tablename()</strong></span>
     接受
     <span class="function"><a href="mysql_list_tables.html" class="function">mysql_list_tables()</a></span>
     返回的结果指针以及一个整数索引作为参数并返回表名。可以用
     <span class="function"><a href="mysql_num_rows.html" class="function">mysql_num_rows()</a></span>
     函数来判断结果指针中的表的数目。用
     <span class="function"><strong>mysql_tablename()</strong></span>
     函数来遍历此结果指针，或者任何处理结果表的函数，例如
     <span class="function"><a href="mysql_fetch_array.html" class="function">mysql_fetch_array()</a></span>。
     <div class="example" id="example-2170">
      <p><strong>Example #1 <span class="function"><strong>mysql_tablename()</strong></span> 例子</strong></p>
      <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />&nbsp;&nbsp;&nbsp;&nbsp;mysql_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">"localhost"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"mysql_user"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"mysql_password"</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$result&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">mysql_list_tables</span><span style="color: #007700">(</span><span style="color: #DD0000">"mydb"</span><span style="color: #007700">);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;(</span><span style="color: #0000BB">$i&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">;&nbsp;</span><span style="color: #0000BB">$i&nbsp;</span><span style="color: #007700">&lt;&nbsp;</span><span style="color: #0000BB">mysql_num_rows</span><span style="color: #007700">(</span><span style="color: #0000BB">$result</span><span style="color: #007700">);&nbsp;</span><span style="color: #0000BB">$i</span><span style="color: #007700">++)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">printf&nbsp;</span><span style="color: #007700">(</span><span style="color: #DD0000">"Table:&nbsp;%s\n"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">mysql_tablename</span><span style="color: #007700">(</span><span style="color: #0000BB">$result</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$i</span><span style="color: #007700">));<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">mysql_free_result</span><span style="color: #007700">(</span><span style="color: #0000BB">$result</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
      </div>

     </div>
    </p>
    <p class="para">
     参见 <span class="function"><a href="mysql_list_tables.html" class="function">mysql_list_tables()</a></span>。
    </p>
   </div>

  </div></div></div></body></html>